<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of datwrite</title>
  <meta name="keywords" content="datwrite">
  <meta name="description" content="DATWRITE Write data to ascii file.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">netlab</a> &gt; datwrite.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../menu.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\netlab&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>datwrite
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>DATWRITE Write data to ascii file.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function datwrite(filename, x, t) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">DATWRITE Write data to ascii file.

    Description

    DATWRITE(FILENAME, X, T) takes a matrix X of input vectors and a
    matrix T of target vectors and writes them to an ascii file named
    FILENAME. The file format is as follows: the first row contains the
    string NIN followed by the number of inputs, the second row contains
    the string NOUT followed by the number of outputs, and the third row
    contains the string NDATA followed by the number of data vectors.
    Subsequent lines each contain one input vector followed by one output
    vector, with individual values separated by spaces.

    See also
    <a href="datread.html" class="code" title="function [x, t, nin, nout, ndata] = datread(filename)">DATREAD</a></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function datwrite(filename, x, t)</a>
0002 <span class="comment">%DATWRITE Write data to ascii file.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">%    Description</span>
0005 <span class="comment">%</span>
0006 <span class="comment">%    DATWRITE(FILENAME, X, T) takes a matrix X of input vectors and a</span>
0007 <span class="comment">%    matrix T of target vectors and writes them to an ascii file named</span>
0008 <span class="comment">%    FILENAME. The file format is as follows: the first row contains the</span>
0009 <span class="comment">%    string NIN followed by the number of inputs, the second row contains</span>
0010 <span class="comment">%    the string NOUT followed by the number of outputs, and the third row</span>
0011 <span class="comment">%    contains the string NDATA followed by the number of data vectors.</span>
0012 <span class="comment">%    Subsequent lines each contain one input vector followed by one output</span>
0013 <span class="comment">%    vector, with individual values separated by spaces.</span>
0014 <span class="comment">%</span>
0015 <span class="comment">%    See also</span>
0016 <span class="comment">%    DATREAD</span>
0017 <span class="comment">%</span>
0018 
0019 <span class="comment">%    Copyright (c) Ian T Nabney (1996-2001)</span>
0020 
0021 nin = size(x, 2);
0022 nout = size(t, 2);
0023 ndata = size(x, 1);
0024 
0025 fid = fopen(filename, <span class="string">'wt'</span>);
0026 <span class="keyword">if</span> fid == -1
0027   error(<span class="string">'Failed to open file.'</span>)
0028 <span class="keyword">end</span>
0029 
0030 <span class="keyword">if</span> size(t, 1) ~= ndata
0031   error(<span class="string">'x and t must have same number of rows.'</span>);
0032 <span class="keyword">end</span>
0033 
0034 fprintf(fid, <span class="string">' nin   %d\n nout  %d\n ndata %d\n'</span>, nin , nout, ndata);
0035 <span class="keyword">for</span> i = 1 : ndata
0036   fprintf(fid, <span class="string">'%13e '</span>, x(i,:), t(i,:));
0037   fprintf(fid, <span class="string">'\n'</span>);
0038 <span class="keyword">end</span>
0039 
0040 flag = fclose(fid);
0041 <span class="keyword">if</span> flag == -1
0042   error(<span class="string">'Failed to close file.'</span>)
0043 <span class="keyword">end</span>
0044</pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>